package com.ruoyi.InboundManagement.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.InboundManagement.service.IScrapInboundService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.InboundManagement.domain.ScrapInbound;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 报废入库管理Controller
 * 
 * @author admin
 * @date 2024-07-02
 */
@RestController
@RequestMapping("/InboundManagement/scrapInbound")
public class ScrapInboundController extends BaseController
{
    @Autowired
    private IScrapInboundService scrapInboundService;

    /**
     * 查询报废入库管理列表
     */
    @PreAuthorize("@ss.hasPermi('InboundManagement:scrapInbound:list')")
    @GetMapping("/list")
    public TableDataInfo list(ScrapInbound scrapInbound)
    {
        startPage();
        List<ScrapInbound> list = scrapInboundService.selectScrapInboundList(scrapInbound);
        return getDataTable(list);
    }

    /**
     * 导出报废入库管理列表
     */
    @PreAuthorize("@ss.hasPermi('InboundManagement:scrapInbound:export')")
    @Log(title = "报废入库管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScrapInbound scrapInbound)
    {
        List<ScrapInbound> list = scrapInboundService.selectScrapInboundList(scrapInbound);
        ExcelUtil<ScrapInbound> util = new ExcelUtil<ScrapInbound>(ScrapInbound.class);
        util.exportExcel(response, list, "报废入库管理数据");
    }

    /**
     * 获取报废入库管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('InboundManagement:scrapInbound:query')")
    @GetMapping(value = "/{scrapId}")
    public AjaxResult getInfo(@PathVariable("scrapId") Long scrapId)
    {
        return success(scrapInboundService.selectScrapInboundByScrapId(scrapId));
    }

    /**
     * 新增报废入库管理
     */
    @PreAuthorize("@ss.hasPermi('InboundManagement:scrapInbound:add')")
    @Log(title = "报废入库管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScrapInbound scrapInbound)
    {
        return toAjax(scrapInboundService.insertScrapInbound(scrapInbound));
    }

    /**
     * 修改报废入库管理
     */
    @PreAuthorize("@ss.hasPermi('InboundManagement:scrapInbound:edit')")
    @Log(title = "报废入库管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScrapInbound scrapInbound)
    {
        return toAjax(scrapInboundService.updateScrapInbound(scrapInbound));
    }

    /**
     * 删除报废入库管理
     */
    @PreAuthorize("@ss.hasPermi('InboundManagement:scrapInbound:remove')")
    @Log(title = "报废入库管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{scrapIds}")
    public AjaxResult remove(@PathVariable Long[] scrapIds)
    {
        return toAjax(scrapInboundService.deleteScrapInboundByScrapIds(scrapIds));
    }
}
